<?php /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id'=>'create-activity',
    'type'=>'horizontal',
    'enableClientValidation'=>true,
    'clientOptions'=>array(
        'validateOnSubmit'=>true,
    ),
)); ?>
 
<fieldset>
     <legend><?php echo $model->isNewRecord ? '新增'.ActivityType::$names[$model->activity_type] : '修改'.ActivityType::$names[$model->activity_type] ?></legend>
    <?php echo $form->errorSummary($model); ?>
    <?php echo $form->textFieldRow($model, 'activity_name'); ?>
    <?php echo $form->dropDownListRow($model, 'activity_type', ActivityType::$names, array('disabled'=>true)); ?>  
    <?php 
        if($model->isNewRecord) {
            $inputForm = new InputForm();
            $inputForm->partition = '{0, 1 day}';
            $inputForm->input_type = ResourceType::Log;
            $model->inputs = array($inputForm);
        }

        if(is_array($model->inputs)) {
            foreach($model->inputs as $input) {
                echo $this->renderPartial('_mrinput', array('model'=>$input));
            } 
        }
    ?> 
    <?php
        if($model->isNewRecord) {
            $outputForm = new OutputForm();
            $model->outputs = array($outputForm);
        }

        if(is_array($model->outputs)) {
            foreach($model->outputs as $output) {
                echo $form->textFieldRow($output, 'output_name', array('hint'=>'<strong>注意:</strong> 请遵循变量的命名方式，不支持中文'));
                echo $form->textFieldRow($output, 'output_desc'); 
                echo $form->dropDownListRow($output, 'output_freq', Frequency::$names); 
                echo $form->checkBoxRow($output, 'output_multiple'); 
            }
        }
    ?> 
    <?php echo $form->textAreaRow($model, 'programs', array('class'=>'span8', 'rows'=>5)); ?>
    <?php echo $form->textFieldRow($model, 'retry_times'); ?>
    <?php echo $form->textAreaRow($model, 'params', array('class'=>'span6', 'rows'=>5)); ?>
</fieldset>
<div class="form-actions">
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary', 'icon'=>'ok white', 'label'=>$model->isNewRecord ? '创 建' : '保 存')); ?>
    <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'reset', 'icon'=>'remove', 'label'=>'取 消')); ?>
</div>
<?php $this->endWidget(); ?>
